#define _CRT_SECURE_NO_WARNINGS  1
#include <stdio.h>

int main() {
    int x = 0;
    scanf("%d", &x);
    int count = 1;
    if (x == 0)
    {
        count = 0;
        printf("%d", count);
        return 0;
    }
    if (x < 0)
    {
        x = 0 - x;
    }
    while (x != 1)
    {
        if ((x % 2) == 1 && ((x + 1) / 2) % 2 == 0 && x > 3)
        {
            count++;
            x += 1;
        }
        else if ((x % 2) == 1)
        {
            count++;
            x -= 1;
        }
        else
        {
            count++;
            x /= 2;
        }
    }
    printf("%d", count);
    return 0;
}